package lab03.test04;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class Test04 {
    public static void main(String[] args) {

        String source = "D:\\旅院\\作业\\java\\1.txt";
        String target = "E:\\picture";

        FileInputStream fileInputStream = null;
        FileOutputStream fileOutputStream = null;



        //使用字节流来读取文件
       // FileInputStream fileInputStream = null;
        //FileOutputStream fileOutputStream = null;

        try {
            try {
                fileInputStream = new FileInputStream(source);
                fileOutputStream = new FileOutputStream(target);

                int data;
                //读一个字节马上就写
                while ((data = fileInputStream.read()) != -1) {
                    fileOutputStream.write(data);
                }
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }finally {
            try {
                fileInputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                fileOutputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }


    }
}
